import http from '@/utils/http'

const BASE_URL = '/testing/uiCaseModule'

export interface UiCaseModuleResp {
  id: string
  projectId: string
  name: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface UiCaseModuleDetailResp {
  id: string
  projectId: string
  name: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface UiCaseModuleQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface UiCaseModulePageQuery extends UiCaseModuleQuery, PageQuery {}

/** @desc 查询UI用例模块列表 */
export function listUiCaseModule(query: UiCaseModulePageQuery) {
  return http.get<PageRes<UiCaseModuleResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询UI用例模块详情 */
export function getUiCaseModule(id: string) {
  return http.get<UiCaseModuleDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增UI用例模块 */
export function addUiCaseModule(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改UI用例模块 */
export function updateUiCaseModule(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除UI用例模块 */
export function deleteUiCaseModule(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出UI用例模块 */
export function exportUiCaseModule(query: UiCaseModuleQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
